package com.gitee.feizns.dynamic.convert.impl;

import com.gitee.feizns.dynamic.DateUtils;
import com.gitee.feizns.dynamic.convert.Converter;

/**
 * <b>任意类型转日期的转换类</b>
 * <p>
 *     适用于的类型：
 *     java.util.Date
 *          -> java.sql.Date
 *          -> java.sql.Time
 *          -> java.sql.Timestamp
 *     java.time.LocalDateTime
 *     java.time.LocalDate
 *     java.time.LocalTime
 * </p>
 * @author feizns
 * @since 2019/5/19 0019
 */
public class ToTimeTypeConverter implements Converter<Object, Object> {

    @Override
    public Object to(Object source, Class<Object> targetType) {
        return DateUtils.parse(source, targetType);
    }

    @Override
    public boolean support(Object source, Class<?> targetType) {
        return DateUtils.support(targetType);
    }

}
